/* GUI CONVERTED from resqwbd.p (converter v1.75) Wed Nov  8 12:55:39 2000 */
/* resqwbd.p - Line Sequence WorkBench- Drop in Planned Work Orders     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/* REVISION: 7.0    LAST MODIFIED: 12/04/91     BY: smm *F230*          */
/* REVISION: 7.0    LAST MODIFIED: 04/06/92     BY: smm *F364*          */
/* REVISION: 7.0    LAST MODIFIED: 05/26/92     BY: emb *F531*          */
/* REVISION: 7.3    LAST MODIFIED: 12/15/92     BY: emb *G468*          */
/* REVISION: 8.5    LAST MODIFIED: 08/25/94     BY: tjs *J014*          */
/* REVISION: 7.3    LAST MODIFIED: 11/22/95     BY: dzn *G1F0*          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb          */
/* REVISION: 9.1      LAST MODIFIED: 08/28/00   BY: *N0PF* Dave Caveney */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00   BY: *N0RS* Mudit Mehta  */

         {mfdeclre.i}
/*N0PF*/ {gplabel.i}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE resqwbd_p_1 "Planned Order"
/* MaxLen: Comment: */

/*N0RS*
 * &SCOPED-DEFINE resqwbd_p_2 " Available Planned Orders "
 * /* MaxLen: Comment: */
 *N0RS*/

/* ********** End Translatable Strings Definitions ********* */


         define shared variable part like pt_part.
         define shared variable site like seq_site.
         define shared variable prline like seq_line.
         define shared variable qtyreq like wo_qty_ord.
         define        variable yn like mfc_logical.
         define        variable sw_reset like mfc_logical.

/*F364*/ define variable idx    like mfc_logical initial no.
/*G468***
 * /*F364*/ define workfile wo1
 * /*F364*/       field w_date    like wo_due_date
 * /*F364*/       field w_nbr     like wo_nbr  column-label "Planned Order"
 * /*F364*/       field w_lot     like wo_lot
 * /*F364*/       field w_part    like wo_part
 * /*F364*/       field w_qty     like wo_qty_ord
 * /*F364*/       field w_log     like wo__log01 format "* /" label "Sel".
 *      */
/*G468*/ define workfile wo1 no-undo
/*G468*/    field w_nbr as character column-label {&resqwbd_p_1}
/*G468*/    field w_date like wo_due_date
/*G468*/    field w_qty like wo_qty_ord
/*G468*/    field w_log like mfc_logical format "***/"
/*G468*/    field w_lot as character.


/*G468*  form w_date w_nbr w_part w_qty w_log
 *       with frame c1 width 80
 *       title color normal "Available Planned Orders"
 *       row 8 down centered overlay.
 * */

/*G468*/ FORM /*GUI*/  w_log no-label w_nbr w_date w_qty
/*G468*/ with frame c1 column 35
/*G1F0* /*G468*/ title color normal "Available Planned Orders" */
/*N0RS* /*G1F0*/ title color normal {&resqwbd_p_2} */
/*N0RS*/ title color normal getFrameTitle("AVAILABLE_PLANNED_ORDERS",35)
/*G468*/ row 9 down overlay THREE-D /*GUI*/.


/*N0PF*/ setFrameLabels(frame c1:handle).

         sw_reset = yes.
         qtyreq = 0.

         /* Get all planned orders for this item */
         for each wo_mstr no-lock where wo_site = site
/*J014*/ and wo_joint_type = ""
         and wo_part = part and wo_status = "P"
/*G468*/ and wo_qty_ord - wo_qty_chg > 0
         use-index wo_part:
            create wo1.
            assign
/*G468*        w_part = wo_part */
               w_nbr = wo_nbr
               w_lot = wo_lot
               w_qty = wo_qty_ord
/*G468*/                 - wo_qty_chg
               w_date = wo_due_date.
         end.

/*G468*/ find first wo1 no-error.
/*G468*/ if not available wo1 then leave.
/*G468*/ pause 0 no-message.

         view frame c1.
/*G468*/ clear frame c1 all no-pause.

         mainloop:
         repeat on endkey undo mainloop, leave:
/*GUI*/ if global-beam-me-up then undo, leave.

/*G468*     clear frame c1 all no-pause. */

/*G468*     {rescrad.i wo1 " " w_nbr "w_nbr w_qty w_part w_date w_log"
 *          w_nbr c1 "yes" } */

/*G468*/    {rescrad.i wo1 " " w_nbr "w_log w_nbr w_date w_qty" w_nbr c1 yes}

/*G468*/    if false then do:
/*G468*/       update w_nbr validate (true,"") with frame c1.
/*G468*/    end.

            if keyfunction(lastkey) = "GO"
/*G468*/    or recno = ?
/*G468*/    or keyfunction(lastkey) = "END-ERROR"
            then do:

               yn = true.
/*G468*        {mfmsg01.i 12 1 yn} */

               if yn then do:

                  for each wo1 where w_log:
                     qtyreq = qtyreq + w_qty.
                     find wo_mstr
/*G468*/             exclusive-lock
                     where wo_lot = w_lot no-error.
                     if available wo_mstr then do:
/*G468*/                wo_qty_chg = wo_qty_chg + w_qty.

/*G468****
 * /*F531*/             for each wod_det where wod_lot = wo_lot:
 * /*F531*/                {mfmrw.i "wod_det" wod_part wod_nbr wod_lot """"
 *                            ? wod_iss_date "0" "DEMAND"
 *                          "WORK ORDER COMPONENT" wod_site}
 * /*F531*/                 delete wod_det.
 * /*F531*/             end.
 *
 * /*F531*/             for each wr_route where wr_lot = wo_lot:
 * /*F531*/                delete wr_route.
 * /*F531*/             end.
 *
 *                      /* get rid of mrp */
 *                      {mfmrw.i "wo_mstr" wo_part wo_nbr wo_lot """"
 *                       wo_rel_date wo_due_date "0" "SUPPLY"
 *                       "WORK ORDER" wo_site}
 *
 *                      {mfmrwdel.i "wo_scrap" wo_part wo_nbr wo_lot """"}
 *
 *                      delete wo_mstr.
 ******/
                     end.
                  end.

                  leave mainloop.

               end.
               else next mainloop.

            end.

            if recno = ? or
            keyfunction(lastkey) = "END-ERROR" then leave.

/*G468*/    if keyfunction(lastkey) = "return" then do:
               set w_qty with frame c1.
               w_log = yes.
/*G468*/    end.

/*G1F0* /*G468*/ if keyfunction(lastkey) = "get" then do: */
/*G1F0*/    if
/*G1F0*/ /*V8+*/
/*G1F0*/      
/*G1F0*/    keyfunction(lastkey) = "delete-character"
/*G1F0*/   
/*G1F0*/    then do:
/*G468*/       w_log = not w_log.
/*G468*/    end.

            display w_log with frame c1.
/*G468*     sw_reset = yes. */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         hide frame c1.
